package io.renren.modules.common.controller;

import java.util.Arrays;
import java.util.*;

import io.renren.modules.common.viewdo.SelectOption;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.common.entity.CompanyPropertyEntity;
import io.renren.modules.common.service.CompanyPropertyService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author nyc
 * @email 2691778746@qq.com
 * @date 2022-03-09 12:39:27
 */
@RestController
@RequestMapping("common/companyproperty")
public class CompanyPropertyController {
    @Autowired
    private CompanyPropertyService companyPropertyService;

    @GetMapping("/list-option")
    public R listOption(){

        List<SelectOption> listData = companyPropertyService.listOption();

        return R.ok().put("data",listData);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("common:companyproperty:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = companyPropertyService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("common:companyproperty:info")
    public R info(@PathVariable("id") Integer id){
		CompanyPropertyEntity companyProperty = companyPropertyService.getById(id);

        return R.ok().put("companyProperty", companyProperty);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("common:companyproperty:save")
    public R save(@RequestBody CompanyPropertyEntity companyProperty){
		companyPropertyService.save(companyProperty);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("common:companyproperty:update")
    public R update(@RequestBody CompanyPropertyEntity companyProperty){
		companyPropertyService.updateById(companyProperty);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("common:companyproperty:delete")
    public R delete(@RequestBody Integer[] ids){
		companyPropertyService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
